package com.seven.tools.cron;

import java.text.SimpleDateFormat;
import java.util.Date;

public class CronTriggerUtils {

    /**
     * Cron时间转换工具
     * @param date 日期
     * @param weeks 1周日、2周一 1,2周日周一...
     * @return
     */
    public static String getCronString(Date date, String weeks) {
        String[] split = weeks.split(",");
        StringBuilder result = new StringBuilder(new SimpleDateFormat("ss mm HH ? * ").format(date));
        for (int i = 0; i < split.length; i++) {
            if (i != split.length - 1) {
                result.append(split[i].trim()).append(",");
            } else {
                result.append(split[i]);
            }
        }
        return result.toString();
    }

}
